package com.hong.qrpc.strategy.invoker.config;

import com.hong.config.constant.ClientConfig;
import com.hong.qrpc.RpcClient;
import com.hong.qrpc.config.ConfigManager;
import com.hong.qrpc.strategy.PropertiesStrategy;
import com.hong.qrpc.utils.StringUtils;

/**
 * @Author HQT
 * @Date 2022/8/3 16:47
 */
public class TimeoutStrategy implements PropertiesStrategy {
    @Override
    public void disposeProperties(RpcClient rpcClient) {
        ConfigManager configManager = rpcClient.getConfigManager();
        String timeout = (String) configManager.getProfile().get(ClientConfig.QRPC_NUMBER_OF_TIMEOUT);
        if (!StringUtils.isEmpty(timeout)) {
            long timeoutVal = Long.parseLong(timeout);
            configManager.getInvokerConfig().setNumberOfTimeout(timeoutVal);
        }
    }
}
